#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@crane-pc>
#
# Distributed under terms of the MIT license.

"""

"""

from math import factorial, pi


def series(nth, item_func, base_from=1):
    idxs = range(base_from, nth+base_from)
    return sum(map(item_func, idxs))


def sin_series():
    def item_func(idx):
        x = pi / 2
        power = 2*idx-1
        co = (-1) ** (idx + 1)
        return co * (x**power/ factorial(power))

    s = series(35, item_func, base_from=1)
    return s

def e():
    def item_func(idx):
        x = 1 # (e^x)
        # power = idx
        # return x**power/ factorial(power)
        return x / factorial(idx)

    s = series(40, item_func, base_from=0)
    return s

def main():
    print("start main")
    s = sin_series()
    print(s)

    e_v = e()
    print(e_v)

if __name__ == "__main__":
    main()
